<?php
include_only();

if(!empty($action) and $action=='delete')
{
$video_information = get_video_information($video_id);

$video_file_name = $video_information['url'];
$image0 = $video_information['image0'];
$image1 = $video_information['image1'];
$image2 = $video_information['image2'];
$image3 = $video_information['image3'];

//unlink("videos/".$video_file_name);
if($image0!='')unlink("thumbnails/".$image0);
if($image1!='')unlink("thumbnails/".$image1);
if($image2!='')unlink("thumbnails/".$image2);
if($image3!='')unlink("thumbnails/".$image3);

mysql_query("DELETE FROM `videos` WHERE `id` = $video_id LIMIT 1");
//print_r($video_information);
}

if(!empty($action) and $action=='play')
{

}

function function_get_user_videos()
{
$user_information = get_user_info();
$user_id = $user_information['id'];

$all_user_videos = get_user_videos($user_id);
//print_r($all_user_videos);

$page= "<table border='0' width='%100' cellspacing='0' cellpadding='0'>";
$page=$page. "<tr><td style='width:10px'>#</td><td style='width:600px'>file name</td><td style='width:20px'></td><td style='width:20px'></td></tr>";
$count=0;
for ($i = 0; $i <= count($all_user_videos)-1; $i++) {
if(strlen($all_user_videos[$i]['name'])>70){
$name = substr($all_user_videos[$i]['name'], 0,70)." ...";
}
else
{
$name = $all_user_videos[$i]['name'];
}
	$count++;
    $page=$page."
	<tr>
	<td>".$count."</td>
	<td>".$name."</td>
	<form method='get' action='index.php'>
	<td>
	<input type='hidden' name='page' value='video_player' />
	<input type='hidden' name='video_id' value='".$all_user_videos[$i]['id']."'/>
	<input type='hidden' name='action' value='play' />
	<input type='image' src='templates/".read_option('theme_folder')."/control/play.gif' />
	</form>
	</td>
	<td>
	<form method='get' action='index.php'><td><input type='hidden' name='page' value='my_videos' />
	<input type='hidden' name='video_id' value='".$all_user_videos[$i]['id']."'/>
	<input type='hidden' name='action' value='delete' />
	<input type='image' src='templates/".read_option('theme_folder')."/control/del.gif' />
	</td>
	</form>
	</tr>
	";
}

$page=$page."</table>";
return($page);
}

$user_videos = function_get_user_videos();
?>